using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using NHibernate.Expression;
using VS.Model;

namespace VS.Facade
{
    public class PTypeSystem
    {
        #region Singleton Instance

        private static readonly PTypeSystem x = new PTypeSystem();

        public static PTypeSystem Instance
        {
            get { return x; }
        }

        #endregion

        public IList GetPType(int status,int pid) {
            DetachedCriteria xICriteria = DetachedCriteria.For(typeof(VS_PType));
            xICriteria.AddOrder(Order.Desc("SortID"));
            xICriteria.Add(Expression.Eq("Status", (byte)status));
            xICriteria.Add(Expression.Eq("PID", pid));
            return VS_PType.FindAll(xICriteria);
        }

        public void DelPType(int id) {
            VS_PType type = VS_PType.Find(id);
            DetachedCriteria xICriteria = DetachedCriteria.For(typeof(VS_PType));
            xICriteria.Add(Expression.Eq("PID", type.VS_PTypeID));
            IList list = VS_PType.FindAll(xICriteria);
            foreach(VS_PType item in list){
                item.Delete();
            }
            type.Delete();
        }
    }
}